Skip to content

Conversation

joshtriplett
Copy link
Member

Rust's niche handling allows for wrapping valid ranges with end < start;
for instance, a valid range with start=43 and end=41 means a niche of
42. Most places in the compiler handle this correctly, but
ty_find_init_error assumed that lo > 0 means the type cannot contain a
zero.

Fix it to handle wrapping ranges.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 22, 2022
@rust-highfive
Copy link
Contributor

r? @cjgillot

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 22, 2022
@joshtriplett
Copy link
Member Author

r? @oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned cjgillot Oct 22, 2022
@oli-obk
Copy link
Contributor

oli-obk commented Oct 22, 2022

I think we already have layout_scalar_valid_range ui tests, please add a test for this case to them

@joshtriplett
Copy link
Member Author

Added a test, waiting for the test failure to give me the updated output.

@joshtriplett joshtriplett force-pushed the niche-wrap-fix branch 3 times, most recently from 0dcce9e to b6b3af3 Compare October 22, 2022 23:14
@rust-log-analyzer

This comment has been minimized.

Rust's niche handling allows for wrapping valid ranges with end < start;
for instance, a valid range with start=43 and end=41 means a niche of
42. Most places in the compiler handle this correctly, but
ty_find_init_error assumed that `lo > 0` means the type cannot contain a
zero.

Fix it to handle wrapping ranges.

Add a test to cover this case.
@joshtriplett
Copy link
Member Author

@oli-obk OK, I think this is ready now. Good call adding a test.

@oli-obk
Copy link
Contributor

oli-obk commented Oct 23, 2022

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Oct 23, 2022

📌 Commit 36662df has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 23, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Oct 23, 2022
…-obk

Fix wrapped valid-range handling in ty_find_init_error

Rust's niche handling allows for wrapping valid ranges with end < start;
for instance, a valid range with start=43 and end=41 means a niche of
42. Most places in the compiler handle this correctly, but
`ty_find_init_error` assumed that `lo > 0` means the type cannot contain a
zero.

Fix it to handle wrapping ranges.
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 24, 2022
Rollup of 11 pull requests

Successful merges:

 - rust-lang#100462 (Clarify `array::from_fn` documentation)
 - rust-lang#101644 (Document surprising and dangerous fs::Permissions behaviour on Unix)
 - rust-lang#103005 (kmc-solid: Handle errors returned by `SOLID_FS_ReadDir`)
 - rust-lang#103140 (Add diagnostic for calling a function with the same name with unresolved Macro)
 - rust-lang#103254 (rustdoc: do not filter out cross-crate `Self: Sized` bounds)
 - rust-lang#103347 (bootstrap: also create rustc-src component in sysroot)
 - rust-lang#103402 (Fix wrapped valid-range handling in ty_find_init_error)
 - rust-lang#103414 (Pretty print lifetimes captured by RPIT)
 - rust-lang#103424 (rustdoc: remove no-op CSS `.code-header { border-bottom: none }`)
 - rust-lang#103434 (Use functions for jump-to-def-background rustdoc GUI test)
 - rust-lang#103447 (`MaybeUninit`: use `assume_init_drop()` in the partially initialized array example)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9f06fbd into rust-lang:master Oct 24, 2022
@rustbot rustbot added this to the 1.66.0 milestone Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants